
cd "C:\Research\Tornadoes\0515Miles_CountyM\"

local size "lt3 gt3lt7 gt7"
foreach s of local size{
use Data\bgfips_level_allyears_wide_final_`s'.dta, clear

gen firm_rs = firm_retail + firm_service
gen emp_rs = emp_retail + emp_service
gen sales_rs = sales_retail + sales_service

keep bgfips year firm_all emp_all sales_all firm_rs emp_rs sales_rs
rename firm_all firm_`s'_all
rename emp_all emp_`s'_all
rename sales_all sales_`s'_all
rename firm_rs firm_`s'_rs
rename emp_rs emp_`s'_rs
rename sales_rs sales_`s'_rs
save "Temp\bgfips_level_allyears_wide_final_`s'_cleaned.dta", replace
}

use Data\bgfips_level_allyears_wide_final.dta, clear
merge 1:1 bgfips year using "Temp\bgfips_level_allyears_wide_final_lt3_cleaned.dta"
tab _merge
drop _merge
merge 1:1 bgfips year using "Temp\bgfips_level_allyears_wide_final_gt3lt7_cleaned.dta"
tab _merge
drop _merge
merge 1:1 bgfips year using "Temp\bgfips_level_allyears_wide_final_gt7_cleaned.dta"
tab _merge
drop _merge
keep bgfips year firm_lt3_all-sales_gt7_all *_rs
save Data\bgfips_level_allyears_wide_final_sizev2.dta, replace
